//
//  RBHomeAtyZoneBrandView.m
//  zhongzhenglu
//
//  Created by XL on 2022/5/26.
//

#import "RBHomeAtyZoneBrandView.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import <Masonry.h>
#import "RBImageBannerView.h"

@interface RBHomeAtyZoneBrandView ()

@property(nonatomic, strong) RBImageBannerView *bannerView;

@end

@implementation RBHomeAtyZoneBrandView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = UIColor.whiteColor;
    }
    return self;
}

- (void)setData:(NSArray *)data
{
    _data = data;
    NSMutableArray *arrayM = NSMutableArray.array;
    for (RBHomeBannerModel *model in data)
    {
        if(model.picurl)
        {
            [arrayM addObject:model.picurl];
        }
    }
    self.bannerView.dataSource = arrayM;
}

+ (CGFloat)suggestViewHeight
{
    return Zoom(93);
}

- (RBImageBannerView *)bannerView
{
    if(!_bannerView)
    {
        self.bannerView = ({
            __weak typeof(self) weak_self = self;
            RBImageBannerView *view = RBImageBannerView.new;
            view.selectBlock = ^(NSInteger index) {
                if(weak_self.block)
                {
                    weak_self.block(index);
                }
            };
            [view rbSetCornerRadius:Zoom(7.5)];
            [self addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(Zoom(17));
                make.right.mas_equalTo(Zoom(-17));
                make.top.bottom.mas_equalTo(0);
            }];
            view;
        });
    }
    return _bannerView;
}

@end
